<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/common/include/header.jsp" %>
<%@ page import="model.*" %>


<div> 
	<table style="border: 0" cellpadding="0" cellspacing="0" border="0" style="width:980px">
		<%-- 왼쪽 메뉴--%>
			<tr>
				<td style="vertical-align: top;width: 180px;background-color: #fdb73a;">
					<%@ include file="/common/include/leftmenu.jsp" %>
				</td>

		<%-- 오른쪽 게시판 list--%>	
				<td style="text-align: center;width: 800px;background: #ffffff; vertical-align: top;">
					<div>
						<html:form action="/qnaboard.do">
						<%@include file="logo.jsp" %>	
						<div class="boardname">질문&답변게시판</div>						
							<table  cellpadding="0" cellspacing="0" border="0" style="width: 700px; text-align: center;">
								<tr style="height: 20px">
									<td style="width: 50px;text-align: center;background-image: url('<%=imagePath %>boardlist_topbg_01.jpg');" class="fbtd2"></td>
									<td style="width: 100px;text-align: center;background-image: url('<%=imagePath %>boardlist_topbg_02.jpg');" class="fbtd2"></td>									
									<td style="background-image: url('<%=imagePath %>boardlist_topbg_03.jpg');" class="fbtd2"></td>
									<td style="width: 100px;text-align: center;background-image: url('<%=imagePath %>boardlist_topbg_04.jpg');" class="fbtd2"></td>
									<td style="width: 50px;text-align: center;background-image: url('<%=imagePath %>boardlist_topbg_05.jpg');" class="fbtd2"></td>
								</tr>							
								<logic:iterate id="list" name="qnaForm" property="qblist" >
									<tr id="<bean:write name="list" property="qbno"/>" onmouseover="changeBGC(<bean:write name="list" property="qbno"/>)" onmouseout="returnBGC(<bean:write name="list" property="qbno"/>)">
										<td class="fbtd" style="width: 50px;text-align: center"><bean:write name="list" property="rownum"/></td>					
										<td class="fbtd" style="width: 100px;text-align: center"><a href="javascript:;" onmousedown="popmenu1('<bean:write name="list" property="mid"/>');"><bean:write name="list" property="mid"/></td>																				
										<td class="fbtd" style="text-align: left;">
										<a href="qnaboard.do?method=detailview&qbno=<bean:write name="list" property="qbno"/>">
										<bean:write name="list" property="qbtitle"/></a></td>
										<td class="fbtd" style="width: 100px;text-align: center"><bean:write name="list" property="qbdate"/></td>
										<td class="fbtd" style="width: 50px;text-align: center"><bean:write name="list" property="qbcounter"/></td>									
									</tr>
								</logic:iterate>				
						
								<%-- 페이징 --%>		
								<tr>
									<td colspan="5">
								<%if (request.getParameter("qnasearch")!=null){ %>
								
								<%  if(request.getParameter("qnasearch").matches("mid")){ %>
								<jsp:include page="pager.jsp">
								<jsp:param name="url" value="qnaboard.do?method=list&qnasearch=mid"/>
								</jsp:include>
								<% } else if(request.getParameter("qnasearch").matches("qbtitle")){ %>
								<jsp:include page="pager.jsp">
								<jsp:param name="url" value="qnaboard.do?method=list&qnasearch=qbtitle"/>
								</jsp:include>
								<%}
								} else { %>
								<jsp:include page="pager.jsp">
								<jsp:param name="url" value="qnaboard.do?method=list"/>
								</jsp:include>
								<% } %>

									</td>
								</tr>
	
								<tr>
									<td  style="text-align: right;" colspan="5">
										<html:link href="javascript:qnaForm.submit();"><img src="<%=imagePath %>icon_write.jpg"/></html:link>			
									</td>
								</tr>
							</table>
					</div>
					<div>
						<%-- 검색 --%>		
							<table>
								<tr>
									<td>			
										<html:select property="qnasearch">
											<html:option value="qbtitle" >제목</html:option>
											<html:option value="mid" >작성자</html:option>
										</html:select>
										<html:text property="qnasearchfield" size="30"/>
										<html:link href="javascript:validate();"><img src="<%=imagePath %>icon_search.jpg"/></html:link>
									</td>
								</tr>
							<input type="hidden" name = "method" value="insertForm"/>
							<input type="hidden" name ="qnasearch" value = "<bean:write name="qnaForm" property="qnasearch"/>"/>
							<input type="hidden" name ="qnasearchfield" value = "<bean:write name="qnaForm" property="qnasearchfield"/>"/>							
							</table>
				
						</html:form>														
					</div>		
								
				</td>
			</tr>
		</table>
	</div>					

<%@ include file="/common/include/footer.jsp"%>
<script type="text/javascript">


// 검색 부분 유효성 검사
	function validate(){	
		var qnasearchfield= document.getElementById('qnasearchfield').value.replace(/\s/g,"");
		var list = document.getElementById('qnaForm');
		document.getElementById('method').value='list';
		var qnasearch = document.getElementById('qnasearch').value;
	
		if(qnasearchfield.length>0){
			if(qnasearch=='qbtitle'){
				list.submit();
			}			
			if(qnasearch=='qbcontent'){		
				list.submit();
			}
			if(qnasearch=='mid'){
				list.submit();
			}
		} else{
			alert("검색어를 입력해주세요");
		}
	}

</script>